package com.sx.jys.ui.adapter

import android.content.Context
import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter
import com.sx.jys.R
import com.sx.jys.app.framework.DiffUtilCallbacks
import com.sx.jys.app.net.bean.CheckBean
import com.sx.jys.databinding.ItemCheckBinding

class ItemCheckAdapter(context: Context, val selectBean: MutableList<CheckBean>) :
    SimpleDataBindingAdapter<CheckBean, ItemCheckBinding>(
        context,
        R.layout.item_check, DiffUtilCallbacks().getItemCallBack()
    ) {
    override fun onBindItem(
        binding: ItemCheckBinding,
        item: CheckBean,
        holder: RecyclerView.ViewHolder
    ) {
        binding.tvStatus.setText(item.name.orEmpty())
        binding.layoutTv.isSelected = selectBean.contains(item)
        if (selectBean.contains(item)) {
            binding.tvStatus.paint.isFakeBoldText = true
            binding.tvStatus.setTextColor(Color.WHITE)
        } else {
            binding.tvStatus.paint.isFakeBoldText = false
            binding.tvStatus.setTextColor(mContext.getColor(com.sos.widget.R.color.c_333333))
        }
    }
}